package com.lzq.feignservice.service.impl;

import com.google.common.collect.Lists;
import com.lzq.feignservice.domain.CommonResult;
import com.lzq.feignservice.domain.User;
import com.lzq.feignservice.service.UserService;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class UserFallbackService implements UserService {

    @Override
    public CommonResult<Object> create(User user) {
        User defaultUser = new User(-1L, "defaultUser", "defaultPassword");
        return new CommonResult<>(defaultUser);
    }

    @Override
    public CommonResult<User> getUser(Long id) {
        User defaultUser = new User(-1L, "defaultUser", "defaultPassword");
        return new CommonResult<>(defaultUser);
    }

    @Override
    public CommonResult<List<User>> getUserByIds(List<Long> ids) {
        User defaultUser = new User(-1L, "defaultUser", "defaultPassword");
        return new CommonResult<>(Lists.newArrayList(defaultUser));
    }

    @Override
    public CommonResult<User> getByUsername(String username) {
        User defaultUser = new User(-1L, "defaultUser", "123456");
        return new CommonResult<>(defaultUser);
    }

    @Override
    public CommonResult<Object> update(User user) {
        return CommonResult.success();
    }

    @Override
    public CommonResult<Object> delete(Long id) {
        return CommonResult.success();
    }
}
